package br.com.sgo.interceptor;

import br.com.caelum.vraptor.InterceptionException;
import br.com.caelum.vraptor.Intercepts;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.core.InterceptorStack;
import br.com.caelum.vraptor.interceptor.Interceptor;
import br.com.caelum.vraptor.resource.ResourceMethod;
import br.com.sgo.util.ApplicationProperties;

@Intercepts
public class ApplicationInterceptor implements Interceptor {

	private final Result result;
	private final ApplicationProperties applicationProperties;

	public ApplicationInterceptor(Result result, ApplicationProperties projetoProperties) {
		this.result = result;
		this.applicationProperties = projetoProperties;
	}

	public boolean accepts(ResourceMethod method) {
		return true;
	}

	public void intercept(InterceptorStack stack, ResourceMethod method, Object resourceInstance) throws InterceptionException {
		this.result.include("applicationProperties", applicationProperties);
		stack.next(method, resourceInstance);
	}

}